﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using wUniAppPCL.IO;
using wUniAppPCL.Loacalization;
using wUniAppPCL.MVVM;

namespace wUniAppPCL
{
  public class DetailViewModel : FilteredPatientsViewModel
  {
    public DetailViewModel(PatientsViewModel patientsViewModel) : base(patientsViewModel)
    {
      Averages = new Averages();
      Collection = new ObservableCollection<ChartData>();
      PropertyChanged += DetailViewModel_PropertyChanged;
    }

    void DetailViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
      if ((e.PropertyName == "SelectedItem") && (SelectedItem != null))
      {
        Collection.Clear();
        Collection.Add(new ChartData("Age", SelectedItem.Age));
        Collection.Add(new ChartData("Height", SelectedItem.Height));
        Collection.Add(new ChartData("Weight", SelectedItem.Weight));
      }
    }

    public Averages Averages { get; private set; }
    
    public ObservableCollection<ChartData> Collection { get; private set; }


    //internal void ApplyFilter(Person person, IList<Person> items)
    //{
    //  if (person != null)
    //  {
    //     var filter = new FilterHelper<Person>();
    //     IList<Person> siblings = Items;
    //     filter.ApplyFilter(person.LastName, items, ref siblings);
    //  }
    //}
  }

  public class ChartData
  {
    public string X { get; set; }
    public double Y { get; set; }

    public ChartData(string x, double y)
    {
      X = x;
      Y = y;
    }
  }
}
